# -*- coding: utf-8 -*-
"""
API 请求数据模型

@author: AI Assistant
"""
from typing import Optional, Dict, Any, List
from pydantic import BaseModel, Field


class SessionQueryRequest(BaseModel):
    """查询会话参数请求"""
    session_id: str = Field(..., description="会话ID")
    
    class Config:
        json_schema_extra = {
            "example": {
                "session_id": "abc123-def456-ghi789"
            }
        }


class ChatRequest(BaseModel):
    """对话请求"""
    session_id: str = Field(..., description="会话ID")
    message: str = Field(..., description="用户消息", min_length=1, max_length=2000)
    conversation_id: Optional[str] = Field(None, description="对话ID（用于继续之前的对话）")
    
    class Config:
        json_schema_extra = {
            "example": {
                "session_id": "abc123-def456-ghi789",
                "message": "请将初始水位提高 10cm",
                "conversation_id": "conv_20240101_001"
            }
        }


class ParameterUpdateRequest(BaseModel):
    """参数更新请求"""
    session_id: str = Field(..., description="会话ID")
    parameter_changes: Dict[str, Any] = Field(..., description="参数修改，格式：{'path.to.param': value}")
    reason: Optional[str] = Field(None, description="修改原因")
    
    class Config:
        json_schema_extra = {
            "example": {
                "session_id": "abc123-def456-ghi789",
                "parameter_changes": {
                    "initial_state.water_level": 100.5,
                    "parameters.K": 0.8
                },
                "reason": "根据用户要求调整参数"
            }
        }


class ParameterValidationRequest(BaseModel):
    """参数验证请求"""
    session_id: str = Field(..., description="会话ID")
    parameter_changes: Dict[str, Any] = Field(..., description="要验证的参数修改")
    
    class Config:
        json_schema_extra = {
            "example": {
                "session_id": "abc123-def456-ghi789",
                "parameter_changes": {
                    "initial_state.water_level": 100.5
                }
            }
        }


class ConversationHistoryRequest(BaseModel):
    """获取对话历史请求"""
    conversation_id: str = Field(..., description="对话ID")
    limit: Optional[int] = Field(None, description="限制返回的条数", ge=1, le=100)
    
    class Config:
        json_schema_extra = {
            "example": {
                "conversation_id": "conv_20240101_001",
                "limit": 50
            }
        }

